﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RestAndPlay.Core.Repository
{
    public static class RepositoryFactory
    {

        #region PlaylistRepository Singleton

        private static volatile PlaylistRepository playlistRepository;
        private static object playlistRepositorySyncRoot = new Object();

        private static PlaylistRepository PlaylistRepository
        {
            get 
            {
                if (playlistRepository == null) 
                {
                    lock (playlistRepositorySyncRoot) 
                {
                    if (playlistRepository == null)
                        playlistRepository = new PlaylistRepository();
                }
                }

                return playlistRepository;
            }
        }

        #endregion

        #region ActionsRepository Singleton

        private static volatile ActionsRepository actionsRepository;
        private static object actionsRepositorySyncRoot = new Object();

        private static ActionsRepository ActionsRepository
        {
            get
            {
                if (actionsRepository == null)
                {
                    lock (actionsRepositorySyncRoot)
                    {
                        if (actionsRepository == null)
                            actionsRepository = new ActionsRepository();
                    }
                }

                return actionsRepository;
            }
        }

        #endregion

        public static PlaylistRepository GetPlaylistRepository()
        {
            return PlaylistRepository;
        }

        public static ActionsRepository GetActionsRepository()
        {
            return ActionsRepository;
        }

    }
}
